﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.MemoPattern.GameRole
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 传统写法
            //{
            //    //大战Boss前
            //    GameRole lixiaoyao = new GameRole();
            //    lixiaoyao.GetInitState();
            //    lixiaoyao.StateDisplay();

            //    //保存进度
            //    GameRole backup = new GameRole();
            //    backup.Vitality = lixiaoyao.Vitality;
            //    backup.Attack = lixiaoyao.Attack;
            //    backup.Defense = lixiaoyao.Defense;

            //    //大战Boss时，损耗严重
            //    lixiaoyao.Fight();
            //    lixiaoyao.StateDisplay();

            //    //恢复之前状态
            //    lixiaoyao.Vitality = backup.Vitality;
            //    lixiaoyao.Attack = backup.Attack;
            //    lixiaoyao.Defense = backup.Defense;

            //    lixiaoyao.StateDisplay();
            //}
            #endregion

            #region 备忘录模式写法
            {
                //大战Boss前
                GameRole lixiaoyao = new GameRole();
                lixiaoyao.GetInitState();
                //打印状态
                lixiaoyao.StateDisplay();

                //保存进度
                RoleStateCaretaker stateAdmin = new RoleStateCaretaker();
                stateAdmin.Memento = lixiaoyao.SaveState();

                //大战Boss时，损耗严重
                lixiaoyao.Fight();
                lixiaoyao.StateDisplay();

                //恢复之前状态
                lixiaoyao.RecoveryState(stateAdmin.Memento);
                //打印状态
                lixiaoyao.StateDisplay();
            }
            #endregion
            Console.Read();
        }
    }
}
